package com.x.erp.service;

import java.util.List;

import com.x.erp.model.CarLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.CarOrderDao;
import com.x.erp.manage.CarOrderManage;
import com.x.erp.model.CarOrder;
import com.x.erp.rpc.CarOrderRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;

/**
 * 预订服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.CarOrderRpcService", timeout = 60000)
public class CarOrderService extends BaseService implements CarOrderRpcService {

	@Autowired
	private CarOrderDao carOrderDao;//预订信息DAO

	@Autowired
	private CarOrderManage carOrderManage;//预订信息Manage

	/**
	 * 查询预订列表
	 * @param order
	 * @return
	 */
	@Override
	public List<CarOrder> selectCarOrderList(CarOrder order){
		try {
			return carOrderDao.selectCarOrderList(order);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询预订数量
	 * @param order
	 * @return
	 */
	@Override
	public int selectCarOrderNum(CarOrder order){
		try {
			return carOrderDao.selectCarOrderNum(order);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增预订信息
	 * @param order
	 * @return
	 */
	@Override
	public CarOrder insertCarOrder(CarOrder order, CarLog carLog){
		try {
			return carOrderManage.insertCarOrder(order, carLog);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改预订信息
	 * @param order
	 * @return
	 */
	@Override
	public int updateCarOrder(CarOrder order){
		return this.update(order);
	}

	/**
	 * 删除预订信息
	 * @param carOrder
	 * @return
	 */
	@Override
	public int deleteCarOrder(CarOrder carOrder) {
		return this.delete(carOrder);
	}
}
